<?php
use lvzmen\yii\cms\widgets\markdown\Markdown;
use lvzmen\yii\cms\widgets\markdown\Example;
use yii\bootstrap\Html;
use yii\bootstrap\Tabs;

$html = [
    "markdown0" => <<<M0
## Overview
输入框有很多类型，`yii\helpers\BaseHtml`类分别对它们进行了封装，如下：
- <a href="#catalogue2">input</a>
- <a href="#catalogue3">buttonInput</a>
- <a href="#catalogue4">submitInput</a>
- <a href="#catalogue5">resetInput</a>
- <a href="#catalogue6">textInput</a>
- <a href="#catalogue7">hiddenInput</a>
- <a href="#catalogue8">passwordInput</a>
- <a href="#catalogue9">fileInput</a>

## input
这是个通用方法，通过这个方法可以创建上述任意一个类型的`input`，但是需要更多的代码封装样式，使用方法如下：
M0,
    "example0" => [
        "html" =>
            \yii\helpers\Html::input('text', 'type', 'Text Input', [
                'class' => 'form-control'
            ])
        .
            \yii\helpers\Html::input('hidden', 'type', 'Hidden Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('password', 'type', 'Password Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('button', 'type', 'Button Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('submit', 'type', 'Submit Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('reset', 'type', 'Reset Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('hidden', 'type', 'Hidden Input', [
                'class' => 'form-control',
                'style' => 'margin-top: 10px;'
            ])
        .
            \yii\helpers\Html::input('file', 'city', 'hangzhou', [
                'style' => 'margin-top: 10px;'
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::input('text', 'type', 'Text Input', [
    'class' => 'form-control'
]);
echo Html::input('hidden', 'type', 'Hidden Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
echo Html::input('password', 'type', 'Password Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
echo Html::input('button', 'type', 'Button Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
echo Html::input('submit', 'type', 'Submit Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
echo Html::input('reset', 'type', 'Reset Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
echo Html::input('hidden', 'type', 'Hidden Input', [
    'class' => 'form-control',
    'style' => 'margin-top: 10px;'
]);
//checkbox 是需要<label>标签一起构成的，因此需要额外的代码实现html构建
echo Html::input('checkbox', 'city', 'hangzhou', [
    'style' => 'margin-top: 10px;'
]);
//radio同上
echo Html::input('radio', 'city', 'hangzhou', [
    'style' => 'margin-top: 10px;'
]);
echo Html::input('file', 'city', 'hangzhou', [
    'style' => 'margin-top: 10px;'
]);
EY0,
        "bootstrap" => <<<EB0
<input type="text" class="form-control" name="type" value="Text Input"/>
<input type="hidden" class="form-control" name="type" value="Hidden Input"/>
<input type="password" class="form-control" name="type" value="Password Input"/>
<input type="button" class="form-control" name="type" value="Button Input"/>
<input type="submit" class="form-control" name="type" value="Submit Input"/>
<input type="reset" class="form-control" name="type" value="Reset Input"/>
<input type="hidden" class="form-control" name="type" value="Hidden Input"/>
<input type="checkbox" name="city" value="hangzhou"/>
<input type="radio" name="city" value="hangzhou"/>
<input type="file" name="city" value="hangzhou"/>
EB0
    ],
    "markdown1" => <<<M0
## ButtonInput
其实就是通过`input`来实现按钮的功能，使用方法如下：  
M0,
    "example1" => [
        "html" =>
            \yii\helpers\Html::buttonInput('Default', [
                'class' => "btn btn-default",
                'style' => "margin-right:10px;"
            ]).
            \yii\helpers\Html::buttonInput('Primary', [
                'class' => "btn btn-primary",
                'style' => "margin-right:10px;"
            ]).
            \yii\helpers\Html::buttonInput('Info', [
                'class' => "btn btn-info",
                'style' => "margin-right:10px;"
            ]).
            \yii\helpers\Html::buttonInput('Success', [
                'class' => "btn btn-success",
                'style' => "margin-right:10px;"
            ]).
            \yii\helpers\Html::buttonInput('Danger', [
                'class' => "btn btn-danger",
                'style' => "margin-right:10px;"
            ]).
            \yii\helpers\Html::buttonInput('Warning', [
                'class' => "btn btn-warning",
                'style' => "margin-right:10px;"
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::buttonInput('Default', [
    'class' => "btn btn-default",
]);
echo Html::buttonInput('Primary', [
    'class' => "btn btn-primary",
]);
echo Html::buttonInput('Info', [
    'class' => "btn btn-info",
]);
echo Html::buttonInput('Success', [
    'class' => "btn btn-success",
]);
echo Html::buttonInput('Danger', [
    'class' => "btn btn-danger",
]);
echo Html::buttonInput('Warning', [
    'class' => "btn btn-warning",
]);
EY0,
        "bootstrap" => <<<EB0
<input type="button" class="btn btn-default" value="Default">
<input type="button" class="btn btn-primary" value="Primary">
<input type="button" class="btn btn-info" value="Info">
<input type="button" class="btn btn-success" value="Success">
<input type="button" class="btn btn-danger" value="Danger">
<input type="button" class="btn btn-warning" value="Warning">
EB0
    ],
    "markdown2" => <<<M0
## SubmitButton
这个控件也是一个按钮，主要作用是`Form`表单的提交，用法如下：
M0,
    "example2" => [
        "html" =>
            Html::submitButton('Submit', [
                "class" => "btn btn-primary"
            ]).
            Html::submitButton('Save', [
                "class" => "btn btn-primary",
                "style" => "margin-left: 10px"
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::submitButton('Submit', [
    "class" => "btn btn-primary"
]).
echo Html::submitButton('Save', [
    "class" => "btn btn-primary",
]);
EY0,
        "bootstrap" => <<<EB0
<button type="submit" class="btn btn-primary">
    Submit
</button>
<button type="submit" class="btn btn-primary">
    Save
</button>
EB0
    ],
    "markdown3" => <<<M0
## ResetButton
重置表单，即清空表单的作用，使用方法如下：
M0,
    "example3" => [
        "html" =>
            Html::resetButton('Reset', [
                "class" => "btn btn-success"
            ]).
            Html::resetButton('Clear', [
                "class" => "btn btn-success",
                "style" => "margin-left: 10px"
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::resetButton('Reset', [
    "class" => "btn btn-success"
]).
echo Html::resetButton('Clear', [
    "class" => "btn btn-success",
]);
EY0,
        "bootstrap" => <<<EB0
<button type="reset" class="btn btn-primary">
    Reset
</button>
<button type="reset" class="btn btn-primary">
    Clear
</button>
EB0
    ],
    "markdown4" => <<<M0
## TextInput
可输入的`input`控件，注意要加入`.form-control`类才能有`bootstrap`的样式，用法如下：
M0,
    "example4" => [
        "html" =>
            Html::textInput('city', 'Hang Zhou', [
                "class" => "form-control"
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::textInput('city', 'Hang Zhou', [
    "class" => "form-control"
]);
EY0,
        "bootstrap" => <<<EB0
<input type="text" class="form-control" name="city" value="Hang Zhou">
EB0
    ],
    "markdown5" => <<<M0
## HiddenInput
隐藏域，此控件不会显示在页面上，但是会真实存在，使用方法如下：
M0,
    "example5" => [
        "html" =>
            Html::hiddenInput('id', '1')
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::hiddenInput('id', '1');
EY0,
        "bootstrap" => <<<EB0
<input type="hidden" name="id" value="1">
EB0
    ],
    "markdown6" => <<<M0
## PasswordInput
密码输入框，用法如下：
M0,
    "example6" => [
        "html" =>
            Html::passwordInput('password', '123456', [
                'class' => 'form-control'
            ])
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::passwordInput('password', '123456', [
    'class' => 'form-control'
]);
EY0,
        "bootstrap" => <<<EB0
<input type="password" class="form-control" name="password" value="123456">
EB0
    ],
    "markdown7" => <<<M0
## FileInput
文件上传，需要实现`enctype`属性(`<form enctype="multipart/form-data">`)，用法如下：
M0,
    "example7" => [
        "html" =>
            Html::fileInput('file_name')
        ,
        "yii" => <<<EY0
use yii\bootstrap\Html;
echo Html::fileInput('file_name');
EY0,
        "bootstrap" => <<<EB0
<input type="file" name="file_name">
EB0
    ],
];

foreach($html as $name => $item){
    switch ($name) {
        case strpos($name, "example") !== false:
            echo Example::widget($item);
            break;
        case strpos($name, "markdown") !== false:
            echo Markdown::widget(["content" => $item]);
            break;
        default:
            break;
    }
}